home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3511 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: news.rrz.uni-hamburg.de!rzdspc1!simmons
  2. From: simmons@rzdspc1.informatik.uni-hamburg.de (Geoffrey Simmons)
  3. Newsgroups: comp.lang.c,gnu.gcc.help
  4. Subject: Re: Casting unsigned short as unsigned int -> Bus error
  5. Date: 29 Jan 96 16:54:17 GMT
  6. Organization: University of Hamburg -- Germany
  7. Message-ID: <simmons.822934457@rzdspc1>
  8. References: <simmons.820857453@rzdspc1> <820879186snz@genesis.demon.co.uk> <4e8v6t$bd2@crl.crl.com> <822701517snz@genesis.demon.co.uk>
  9. NNTP-Posting-Host: rzdspc1.informatik.uni-hamburg.de
  10.  
  11. I was amazed to look back into comp.lang.c to find that this thread, which
  12. I started, is still alive.
  13.  
  14. It turned out that the problem I was having was related to alignment, but
  15. had nothing to do with casting unsigned int as unsigned short, so I changed
  16. the Subject: line and went from there.
  17.  
  18. For the record: I was reading data from a database into a struct using
  19. Unix NDBM. The NDBM routines return a pointer, but (as I learned) the fields
  20. in the struct that it points to are not guaranteed to be aligned properly.
  21.  
  22. The solution was to copy the data into a properly-declared struct using
  23. memcpy().
  24.  
  25. Thanks to all who helped,
  26. Geoff
  27. -- 
  28. Geoffrey Simmons     |  simmons@informatik.uni-hamburg.de    | "Insert wise
  29. University of Hamburg     |    Phone: (++49 40) 54715-381    |  and witty
  30. Vogt-Koelln-Str. 30     |    Fax:   (++49 40) 54715-385    |  quotation
  31. D-22527 Hamburg, Germany |                    |  here."
  32.